<?php
//ini_set("display_errors", "On");
//error_reporting(E_ALL | E_STRICT);
require_once "../php/funcs.php";
require_once "../php/pvuvLog.class.php";

$handler = new RedisSessionHandler(
    'UPLUSCLUB_AUTH_SESSION', $CONFIG['REDIS']['HOST'], $CONFIG['REDIS']['PORT']
);
require_once "../php/session_common.php";
$openid = '';//微信授权
if (!session_id()) {
    session_start();
}
$sqlHost = 'localhost';
$sqlUser = 'root';
$sqlPsd  = 'mojitoweilianda318';
$wanmiProjectEn = 'IntegralStoreNext';//万迷项目WanmiAaaBbb，英文
$wanmiProjectCn = '积分商城';//万迷项目，中文
$wanmiProjectUrl = 'wanmi_integral_store_next';//万迷项目路径，中文


$isWeixinBrowser = isWeixinBrowser();
if ($isWeixinBrowser == 1) {
    if (isset($_SESSION['wanmiOpenid'])
        && !empty($_SESSION['wanmiOpenid'])
        && $_SESSION['wanmiOpenid'] != 'unknown'
    ) {
        $openid = $_SESSION['wanmiOpenid'];
    } else {
        //微信授权oauth2授权，获取code
        {
            $_SESSION['referer'] = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
            $redirectUrl = $CONFIG['UrlPrefix']
                ."login.php";
            $redirectUrl = urlencode($redirectUrl);
            $baseUrl     = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="
                .$CONFIG['appid']."&response_type=code&scope=snsapi_base";
            $finalUrl = $baseUrl
                ."&redirect_uri=$redirectUrl&state=wanmi#wechat_redirect";
            header("Location:$finalUrl");

            exit();
        }
    }
} else {
	$openid = 'ozVCVuPJYfQQ3XaFpal_Rs36_50U'; //JYJ
//   $openid = 'osuFbt60ZKkHHner3-bT9PnQPOwg';
//	echo "<h1>请从微信手机端访问，参与活动哦~</h1>";
//	exit();
}

function getMicrotime()
{
    list($usec, $sec) = explode(' ', microtime());
    return ((float)$usec + (float)$sec);
}

?>
